<?php

namespace App\Http\Requests;

use Illuminate\Foundation\Http\FormRequest;
use Illuminate\Http\Request;
use Illuminate\Validation\Rule;

class LevelRequest extends FormRequest
{
    /**
     * Determine if the user is authorized to make this request.
     *
     * @return bool
     */
    public function authorize()
    {
        return true;
    }

    /**
     * Get the validation rules that apply to the request.
     *
     * @return array
     */
    public function rules(Request $request)
    {
        switch ($this->method()) {
            case 'POST':
                $rules =  [
                    'level' => 'required|max:20',
                    'colour' => 'required|max:20'
                ];
                break;
            case 'PATCH':
                $rules =  [
                    'level' => 'required|max:20',
                    'colour' => 'required|max:20'
                ];
                break;
        }
        return $rules;
    }

    public function attributes()
    {
        return [
            'level'=>'等级',
            'colour'=>'颜色属性',
        ];
    }
}
